import unittest
class StringLengthCalculator:
    @staticmethod
    def string_length(s):
        """计算字符串长度"""
        return len(s)
    @staticmethod
    def calculate_string_length(s):
        """计算并返回字符串长度"""
        return len(s)
string_length = StringLengthCalculator.string_length
calculate_string_length = StringLengthCalculator.calculate_string_length

class TestStringLengthCalculator(unittest.TestCase):
    def test_english_string(self):
        """测试英文字符串的长度计算"""
        self.assertEqual(string_length("Hello world"), 11)
        self.assertEqual(calculate_string_length("Hello world"), 11)
    def test_chinese_characters(self):
        """测试中文字符的长度计算"""
        self.assertEqual(string_length("测试用例12345"), 9)  # 4个汉字 + 5个数字
        self.assertEqual(calculate_string_length("测试用例12345"), 9)
    def test_special_characters(self):
        """测试特殊字符的长度计算"""
        self.assertEqual(string_length("[1, 2, 3]"), 7)
        self.assertEqual(calculate_string_length("[1, 2, 3]"), 7)
    def test_dictionary_representation(self):
        """测试字典表示的字符串长度计算"""
        self.assertEqual(string_length("{'key': 'value'}"), 14)
        self.assertEqual(calculate_string_length("{'key': 'value'}"), 14)
    def test_chinese_name(self):
        """测试中文名称的长度计算"""
        self.assertEqual(string_length("张三"), 2)
        self.assertEqual(calculate_string_length("张三"), 2)
    def test_empty_string(self):
        """测试空字符串的处理"""
        self.assertEqual(string_length(""), 0)
        self.assertEqual(calculate_string_length(""), 0)
    def test_type_error(self):
        """测试非字符串输入是否引发类型错误"""
        with self.assertRaises(TypeError):
            string_length(None)
        with self.assertRaises(TypeError):
            calculate_string_length(None)
        
        with self.assertRaises(TypeError):
            string_length(123)
        with self.assertRaises(TypeError):
            calculate_string_length(123)
        
        with self.assertRaises(TypeError):
            string_length([1, 2, 3])
        with self.assertRaises(TypeError):
            calculate_string_length([1, 2, 3])
        
        with self.assertRaises(TypeError):
            string_length({"key": "value"})
        with self.assertRaises(TypeError):
            calculate_string_length({"key": "value"})


if __name__ == "__main__":
    unittest.main()